package netty.myDecoder;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;

/**
 * @Description TODO
 * @Author 李龙平
 * @Date 2020/10/13 17:15
 */
public class MyServer {
    public static void main(String[] args) throws InterruptedException {
        EventLoopGroup boss = new NioEventLoopGroup();
        EventLoopGroup work = new NioEventLoopGroup();

        try {
            ServerBootstrap bootstrap= new ServerBootstrap();
            //自定义初始化类
            bootstrap.group(boss, work).channel(NioServerSocketChannel.class).childHandler(new MyServerInitor());

            ChannelFuture channel = bootstrap.bind(6668).sync();
            channel.channel().closeFuture().sync();
        } finally {
            boss.shutdownGracefully();
            work.shutdownGracefully();
        }
    }
}
